#ifndef RASTERREADER_HPP
#define RASTERREADER_HPP

#include "raster.hpp"

#include <array>
#include <string>

namespace hms::raster
{

/**
 * @brief Class to read ASCII raster files. Aspires to be general-purpose,
 * currently modelled after ESRI ASCII grid files. Hopefully extendable.
 * 
 */
class RasterReader {
public:
	enum class Key {
		nx,
		ny,
		x_corner,
		y_corner,
		x_center,
		y_center,
		cellsize,
		noData,
		nKeys
	};
	static constexpr int nKeys { static_cast<int>(Key::nKeys) };
	bool reverseY {true};

private:
	std::array<std::string, nKeys> m_keys;

public:
	RasterReader() = default;

	RasterReader( std::array<std::string, nKeys>&& );

	auto keys() const -> const std::array<std::string, nKeys>&;
	void keys( std::array<std::string, nKeys>&& );

	auto key( Key ) const -> const std::string&;
	void key( Key, std::string );

	Raster read( std::istream& );

private:
	auto toLower( std::array<std::string, nKeys>&& )
		-> std::array<std::string, nKeys>;
	
	void validate() const;
};

} // namespace hms::raster

#endif